#include "VQColorButton.h"

COLORREF cutomColors1[16];

VQColorButton::VQColorButton( int x, int y, int w, int h )
: VQControl( x, y, w, h ) {
	_brush = CreateSolidBrush( RGB( 0, 0, 0 ) );
}


VQColorButton::~VQColorButton(void) {
}

void VQColorButton::draw( HDC hdc ) {
	HBRUSH ob = (HBRUSH)SelectObject( hdc, _brush );
	Rectangle( hdc, _x, _y, _x+_w-1, _y+_h-1 );
	SelectObject( hdc, ob );
}

void VQColorButton::action( HWND Wnd ) {
	CHOOSECOLOR cc;
	cc.lStructSize = sizeof(cc);
	cc.hwndOwner = Wnd;
	cc.rgbResult = _c;
	cc.lpCustColors = cutomColors1;
	cc.Flags = CC_RGBINIT | CC_FULLOPEN;

	if (ChooseColor( &cc )) {
		setColor( cc.rgbResult );
	}
}